<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片切换</title>
    <style>
        #outer{
            width: 500px;
            height: 500px;
        }
        #inner{
            margin: auto;
            width: 100%;
            height: 300px;
        }
        #img{
            width: 500px;
        }
    </style>
</head>
<body>
    <div id="outer">
        <div id="inner">
            <img id="img" src="../imgs/云海.jpg" alt="img1">
        </div>
        <!-- 控制按钮 -->
        <button onclick="changeImage('../imgs/猫.jpg')">图片1</button>
        <button onclick="changeImage('../imgs/卡通粉熊.jpg')">图片2</button>
        <button onclick="changeImage('../imgs/4k01.jpg')">图片3</button>
    </div>
    <script>
        function changeImage(newSrc) {
            var img = document.getElementById('img');
            img.src = newSrc;
        }
    </script>
</body>
</html>